Socket
Socket
Sign inDemoInstall

staack

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staack

A library to create type-safe opaque stacks


Version published
Maintainers
1
Created
Source

🏯 Staack

A library to create type-safe opaque stacks

Example

// 1. Create a key with a name and a type
const NumKey = Key.create<number>('Num');

// 2. Create a stack
const stack = new Staack();

// 3. Add a value to the stack using the key (Staack is immutable, it returns a new instance)
const stack2 = stack.with(NumKey.Provider(42));

// 4. Get the value from the stack using the key
expect(stack2.get(NumKey.Consumer)).toBe(42);

Installation

npm install staack
# or
yarn add staack

Extending Staack

You can create your own Staack:

class CustomStaack extends Staack {
  // You need to override the `instantiate` method to return a new instance of your CustomStack
  protected instantiate(staackCore: StaackCoreValue): this {
    return new CustomStaack(staackCore) as any;
  }
}

const custom = new CustomStaack();
expect(custom instanceof CustomStaack).toBe(true);
expect(custom instanceof Staack).toBe(true);

Keywords

FAQs

Package last updated on 21 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc